<?php
//require_once('class.soapclient.php');
//require_once('class.soap_val.php');
//require_once('class.soap_parser.php');
//require_once('class.soap_fault.php');
App::import('Vendor','class.soapclient');
App::import('Vendor','nusoap'); 

class AllegroComponent extends Object {	
	var $components = array( 'Auth','Session','RequestHandler');

	
	public function initialize(&$controller) {
		$this->controller = $controller;
		
		$par = array(0=>array('country'=>228,'loginname'=>'21w_test','password'=>'test123'),
					 1=>array('country'=>1,'loginname'=>'21w','password'=>'silky123'),
					 2=>array('country'=>1,'loginname'=>'g-o-s-o','password'=>'GoSo123'),
					 3=>array('country'=>1,'loginname'=>'zdzisiek82','password'=>'135ziko987'));
		$i = 2;
		$this->country = $par[$i]['country'];   // Poland: 1
		$this->loginname = $par[$i]['loginname'];  // 21w
		$this->password = $par[$i]['password'];  // silky123
		$this->apiKey = '8fee66bb82';
		
		$params = array(
			'sysvar' => 1, //which feature you are asking for, 1 is for AllegroWebApi, other possible options above
			'country-id' => $this->country, //country code, 1 is for Poland, all country codes are available in doLogin method documentation  
			'webapi-key' => $this->apiKey //your webapi key
		 );
	 
		try{
			$this->client = new nusoap_client('http://webapi.allegro.pl/uploader.php?wsdl');
			// pobieranie wersji WebAPI
			$this->version = $this->client->call('doQuerySysStatus',$params);
			debug($this->version);
//			$this->version = $this->client->doQuerySysStatus(1, $this->country, $this->apiKey);
			// właściwe logowanie do serwisu
		}catch(SoapFault $soapFault){
			echo $soapFault;
		}		
	}
	
	
}